#include<cstdio>
#include<iostream>
using namespace std;
long long n,l,r,a,num,sum;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	a=l/n;
	if(l%n!=0)a++;
	num=(a-1)*n+n-1;
	sum=a*n+n-1;
	if(num>=l&&num<=r)printf("%lld",n-1);
	else{
		if(sum>=l&&sum<=r)printf("%lld",n-1);
		else{
			if(l%n==0)printf("%lld",r-a*n);
			else printf("%lld",r-(a-1)*n);
		}
	}
}
